require "ym4r/yahoo_maps/building_block/traffic"
include Ym4r::YahooMaps::BuildingBlock
 
class PointsController < ApplicationController
  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @points_pages, @points = paginate :points, :per_page => 10
  end

  def show
    @points = Points.find(params[:id])
  end

  def new
    @points = Points.new
  end

  def create
    @points = Points.new(params[:points])
    if @points.save
      flash[:notice] = 'Points was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

  def edit
    @points = Points.find(params[:id])
  end

  def update
    @points = Points.find(params[:id])
    if @points.update_attributes(params[:points])
      flash[:notice] = 'Points was successfully updated.'
      redirect_to :action => 'show', :id => @points
    else
      render :action => 'edit'
    end
  end

  def destroy
    Points.find(params[:id]).destroy
    redirect_to :action => 'list'
  end

  def map_point
      @map = GMap.new("map_div")
      @map.control_init(:large_map => true,:map_type => true)
      @map.center_zoom_init([38.134557,-95.537109],4)
      @map.icon_global_init(GIcon.new(:image => "/images/icon_incident.png", :icon_size => GSize.new(15,15),:icon_anchor => GPoint.new(7,7),:info_window_anchor => GPoint.new(9,2)),"icon_incident")
      @map.icon_global_init(GIcon.new(:image => "/images/icon_construction.png", :icon_size => GSize.new(15,15),:icon_anchor => GPoint.new(7,7),:info_window_anchor => GPoint.new(9,2)),"icon_construction")
  end
end
